const forEach = (arr, visitor) => {
    this.arr = arr
    var out = []
    for (let i = 0; i < this.arr.length; i++) {
        out.push(visitor(arr[i]))
    }
    return out;
}
class Foreach {
    constructor() {
        this.foreach = forEach
    }
}
function every(arr,predicate){
    var fe = new Foreach()
    var judge = fe.foreach(arr,predicate)
    if(judge.indexOf(false)!=-1) return false
    else return true
}
function some(arr,predicate){
    var fe = new Foreach()
    var judge = fe.foreach(arr,predicate)
    if(judge.indexOf(true)!=-1) return true
    else return false
}
var arr = [1,3,5,7,8]
var p1 = function(elem){
    if(elem>=3){
        return true;
    }
    else return false;
}
console.log(every(arr,p1))
console.log(some(arr,p1))

